package com.meet.dao;

import com.meet.entity.ServletVisitLog;
import com.meet.util.DateUtil;
import com.meet.util.JDBCutil;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class ServletVisitDaoImpl implements ServletVisitDao{
    @Override
    public int AddServletVisitLog(ServletVisitLog servletVisitLog) throws SQLException {
        int count =-1;
        Connection connection = JDBCutil.getConnection();
        PreparedStatement preparedStatement=connection.prepareStatement("insert into daily (ip,servletname,visittime,username) values (?,?,?,?)");
        //preparedStatement.setObject(1,servletVisitLog.getId());
        preparedStatement.setObject(1,servletVisitLog.getIp());
        preparedStatement.setObject(2,servletVisitLog.getServletname());
        preparedStatement.setTimestamp(3,new java.sql.Timestamp(DateUtil.getCurrentTime().getTime()));
      //  preparedStatement.setObject(4,servletVisitLog.getParam());
        preparedStatement.setObject(4,servletVisitLog.getUserName());
        count=preparedStatement.executeUpdate();
        connection.close();
        return count;
    }
}
